package OSdesign.Function_show;


import java.sql.*;

public class MySQL_Conn {
    public Statement stmt= null;
    public ResultSet set = null;
    public Connection conn = null;
    public MySQL_Conn(){

    }
    public void Connect(){
        try{
            Class.forName("com.mysql.cj.jdbc.Driver");
        } catch(ClassNotFoundException classe){
            classe.printStackTrace();
        }
        try{
            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/sportsmanager?" +
                    "useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC","root","wahaha");
            stmt = conn.createStatement();
            System.out.println("连接成功");
        } catch(SQLException sqle){
            sqle.printStackTrace();
        }
        //return stmt;
    }
    public void disConnect(){
        if(conn!=null){
            try {
                conn.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
        if(stmt!=null){
            try {
                stmt.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
        if(set!=null){
            try {
                set.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
    }
    public static void main(String[] args){
        new MySQL_Conn().Connect();
    }
}
